import $http from '@/common/api/request.js'
export default{
	uploadImage(item,postUrl,uploadMsg,uniqueCode){
		console.log(item);
		uni.uploadFile({
			url:postUrl,
			fileType: "image",
			filePath:item,
			name:'file',
			formData:{
				'key':uniqueCode.slice(0,10),
				'token':uploadMsg
			},
			// 经过escape()转转义之后的文件名和图片链接一部分一致
			success: (uploadFileRes) => {
				let key = JSON.parse(uploadFileRes.data).key
				let partImgUrl = escape(uniqueCode.slice(0,10));
				this.partImgUrl.push({
					imgUrl:'http://'+this.qiniuBucketURLPrefix + partImgUrl 
				})
			},
			fail: (err) => {
				console.log('fail',err);
			}
		})
	}
}